function DataStore(syncCallback) {
  this.isOnline = true;
  this._xhr = null;
  this._syncCB = syncCallback;
  this._abortLastRequest = function() {
    if (this._xhr) {
      this._xhr.abort();
      this._xhr = null;
    }
  };
}

DataStore.prototype._initial = function() {
  ;
};

// this could be invoked by user
// @clientUpdate - String data which user originate
DataStore.prototype.sync = function(clientUpdate) {
  // abort last request
  this._abortLastRequest();
  
  // trigger XHR request
  var self = this;
  this._xhr = $.ajax({
    url: '/ezkeypad/ez_heartbeat',
    type: 'GET',
    error: function(xhr, textStatus) {
      self._xhr = null;
      logging('sync error: '+textStatus);
      self.isOnline = false;
      self._syncCB(null);
    },
    success: function(data, textStatus) {
      self._xhr = null;
      //logging('sync success');
      self.isOnline = true;
      self._syncCB(data);
    }
  });
};
